package com.neu.util;

public class ConstUtil {

    //秒杀脚本
    public static final String SKillScript ="local customerId=KEYS[1];\r\n" +
            "local activityId=KEYS[2];\r\n" +
            "local activityKey='activity:'..activityId..\":total\";\r\n" +
            "local bookKey='activity:'..activityId..\":book\";\r\n" +
            "local time=redis.call(\"exists\",activityKey);\r\n" +
            "if tonumber(time)==0 then \r\n" +
            "   return 3;\r\n" +
            "end\r\n" +
            "local exists=redis.call(\"sismember\",bookKey,customerId);\r\n" +
            "if tonumber(exists)==1 then \r\n" +
            "   return 0;\r\n" +
            "end\r\n" +
            "local count= redis.call(\"get\" ,activityKey);\r\n" +
            "if tonumber(count)<=0 then \r\n" +
            "   return 1;\r\n" +
            "else \r\n" +
            "   redis.call(\"decr\",activityKey);\r\n" +
            "   redis.call(\"sadd\",bookKey,customerId);\r\n" +
            "end\r\n" +
            "return 2" ;

}
